<div class="organization-item" style="margin-left: {{ $level * 16 }}px; margin-bottom: 4px;">
    <div class="organization-row border rounded p-2 bg-white hover-shadow">
        <div class="d-flex justify-content-between align-items-center">
            <div class="d-flex align-items-center flex-grow-1">
                @if($organization->children->count() > 0)
                    <span class="toggle-children me-2" data-id="{{ $organization->id }}" style="cursor: pointer; width: 16px; text-align: center;">
                        <i class="fas fa-chevron-down text-muted" style="font-size: 12px;"></i>
                    </span>
                @else
                    <span class="me-2" style="width: 16px;"></span>
                @endif
                
                <div class="d-flex align-items-center flex-wrap">
                    <span class="fw-semibold text-dark me-2">{{ $organization->name }}</span>
                    
                    @if($organization->code)
                        <span class="badge bg-light text-dark border me-1" style="font-size: 10px;">{{ $organization->code }}</span>
                    @endif
                    
                    <span class="badge {{ $organization->is_active ? 'bg-success' : 'bg-danger' }} me-1" style="font-size: 10px;">
                        {{ $organization->is_active ? '活跃' : '禁用' }}
                    </span>
                    
                    <span class="badge bg-info me-1" style="font-size: 10px;">{{ $organization->users->count() }}人</span>
                </div>
            </div>
            
            <div class="btn-group btn-group-sm" role="group">
                <a href="{{ route('admin.organizations.show', $organization) }}" 
                   class="btn btn-outline-secondary btn-xs" title="查看">
                    <i class="fas fa-eye" style="font-size: 11px;"></i>
                </a>
                @can('edit-organizations')
                <a href="{{ route('admin.organizations.edit', $organization) }}" 
                   class="btn btn-outline-warning btn-xs" title="编辑">
                    <i class="fas fa-edit" style="font-size: 11px;"></i>
                </a>
                @endcan
                @can('delete-organizations')
                <form action="{{ route('admin.organizations.destroy', $organization) }}" method="POST" 
                      style="display: inline-block;" 
                      onsubmit="return confirm('确定要删除这个组织吗？')">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn btn-outline-danger btn-xs" title="删除">
                        <i class="fas fa-trash" style="font-size: 11px;"></i>
                    </button>
                </form>
                @endcan
            </div>
        </div>
    </div>
    
    @if($organization->children->count() > 0)
        <div class="children-container" id="children-{{ $organization->id }}" style="display: block;">
            @foreach($organization->children as $child)
                @include('admin.organizations.partials.organization-item', ['organization' => $child, 'level' => $level + 1])
            @endforeach
        </div>
    @endif
</div>